package com.february.todo.tools;
import android.util.Log;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class TimeComparator {
    public Boolean isEarlier;
    public Boolean isLater;

    public TimeComparator(String date,String timeEnd){
        Date curTime = new Date(System.currentTimeMillis()); //获取当前时间

        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA); //设置时间格式
        try {
            Date time = formatter.parse(date + " " + timeEnd);
            assert time != null;
            isEarlier= curTime.getTime()>=time.getTime();
            isLater=!isEarlier;
        }catch (Exception e) {
            Log.i("message", "Time Compare Error");
        }
    }

    public TimeComparator(Date timeStart,Date timeEnd){
        isEarlier= timeEnd.getTime()>timeStart.getTime();
        isLater=!isEarlier;
    }

    public TimeComparator(Date date,String endDate){
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); //设置时间格式
        try {
            Date time = formatter.parse(endDate);
            assert time != null;
            isEarlier= time.getTime()>=date.getTime();
            isLater=!isEarlier;
        }catch (Exception e) {
            Log.i("message", "Time Compare Error");
        }
    }
}
